/*
 * vCLURT.h
 *
 *  Created on: May 21, 2011
 *      Author: ulas
 */

#ifndef VCLURT_H_
#define VCLURT_H_

#include "common/PQ.h"
#include "common/sys.h"
#include "common/CL_Common.h"


typedef struct
{
	U8 nodeId;
	U8 ch;
	U8 initialeT;  //in msec
	U8 initialdT;
	TimeInternal eT;
	TimeInternal dT;
}URT_COMMUNICATION_REQUEST_PQ_TYPE;

class vCLURT {
private:
	PQ_STRUCT* PQ;

public:

	vCLURT();

	STATUS initialize_vCL();

	STATUS insertNodeIntoPQ(void* node);
	void* popNodeFromPQ();
	void* peekNodeFromPQ();
	U32 getPQSize();
	STATUS freePQ();


	virtual ~vCLURT();


	//compare function for PQ
	static U8 comparePriority(void* next, void* curr)
	{
		return ( greaterThan( (TimeInternal*)next, (TimeInternal*)curr));
	}
	//getting priority

	static void* getPriority(void* par)
	{
		return &(((URT_COMMUNICATION_REQUEST_PQ_TYPE*)par)->dT);
	}

};

#endif /* VCLURT_H_ */
